<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="__sid" value="__sid=${cookie[fns:getConfig('session.sessionIdCookieName')].value}" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>打印文档 - ${fns:getConfig('productName')}</title>
	<meta name="renderer" content="ie-stand"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta http-equiv="Expires" content="0">
	<meta http-equiv="Cache-Control" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-store">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
	<strong>批量打印</strong>
	
	<div id="toolbar" style="margin:8px 0;">        
	    <button type="button" onclick="reportWindow.contentPane.gotoFirstPage()">首页</button>        
	    <button type="button" onclick="reportWindow.contentPane.gotoPreviousPage()">上一页</button>         
	    <button type="button" onclick="reportWindow.contentPane.gotoNextPage()">下一页</button>          
	    <button type="button" onclick="reportWindow.contentPane.gotoLastPage()">末页</button>   
	    <input id="page" type="text" readonly="readonly" size="12" style="border:none">到<input id ="index" type ="text" size="3"/>页 
		<button type="button" onclick="gotopage()" >跳转</button>
<!-- 		<button type="button" onclick="reportWindow.contentPane.exportReportToPDF()">导出PDF</button>  -->
<!-- 		<button type="button" onclick="reportWindow.contentPane.flashPrint()">Flash打印</button>  -->
		<button type="button" onclick="webPrint()">Web打印</button> 
	</div>
	
	<iframe id="reportFrame" src="${ctxPath}/ReportServer?reportlet=articleView.cpt&id=644750724277805056"
		style="width:100%; height: 85%; border: 1px solid #aaa" onload="afterload()"></iframe>
		
	<script src="${ctxStatic}/jquery/jquery-1.11.2.min.js" type="text/javascript"></script>
	
	<script src="${ctxStatic}/webprint/jquery.PrintArea.js" type="text/javascript"></script>
	
	<script language="javascript">

		var reportWindow = document.getElementById("reportFrame").contentWindow;
		
		function afterload() {     //iframe加载后触发   
			var contentPane = reportWindow.contentPane;  //获取报表contentPane      
			var cPageIndex = contentPane.currentPageIndex;   //当前所在页   
			var pv = "第" + cPageIndex + "页/共" + contentPane.reportTotalPage + "页";   //报表首次加载结束后显示的页码信息   
			document.getElementById("page").value = pv;     //将页码信息赋给page文本   
			
			contentPane.on("afterload", function() {      //报表加载结束监听事件   
				
				cPageIndex = contentPane.currentPageIndex;      //每次加载完后重新获取当前页码   
				pv = "第" + cPageIndex + "页/共" + contentPane.reportTotalPage + "页";     //重新生成页码信息    
				document.getElementById("page").value = pv;      //重新给page文本赋页码信息      
				document.getElementById("index").value = cPageIndex; // 设置跳转页面为当前页码
				
// 				reportWindow.$('.x-toolbar').hide().resize();
				
// 				var w = reportWindow.$('.pageContentDIV').width();
// 				var h = reportWindow.$('.pageContentDIV').height();
// 				reportWindow.$('.reportPane,.content-container').width(w);
// 				reportWindow.$('.reportPane,.content-container').height(h);
// 				reportWindow.reportPane.focus();
// 				reportWindow.document.body.innerHTML = reportWindow.$('.pageContentDIV').html();
// 				reportWindow.print();
				
	            
			});
		}        
		
		function gotopage() {        
			var contentpane= reportWindow.contentPane;
			var page = document.getElementById("index").value;        
			if(page >= contentpane.reportTotalPage) {        
				contentpane.gotoLastPage();        
			}         
			contentpane.gotoPage(parseInt(page));        
		}   

		function webPrint(){
			reportWindow.contentPane.gotoFirstPage();
			var options = {
				extraCss : '${ctxPath}/ReportServer?op=emb&resource=finereport.css',
			};
			var printContent = reportWindow.$('.pageContentDIV .report-background .page-block');
            $( printContent ).printArea( options );
		}
		
	</script>
<!-- 	<div style="font-size:13px;line-height:24px;margin-top:10px;"> -->
<!-- 		<button onclick="webPrn.PrintSetup();">打印设置</button> &nbsp; -->
<!-- 		<button onclick="webPrn.PrintSetupWebPage()">打印当前页</button> &nbsp; -->
<!-- 		<button onclick="webPrint()">开始批量打印</button> &nbsp; -->
<!-- 		<p><strong>注意事项：</strong><br/> -->
<!-- 		1、推荐使用IE浏览器，如果使用双核浏览器，请切换到IE模式下；<br/> -->
<!-- 		2、然后点击浏览器上方会弹出黄色提示，选择“为此计算机上的所有用户安装此加载项”或点击浏览器下方“安装”按钮，弹出的对话框再点击“安装”即可。<br/> -->
<!-- 		3、打印设置可设置纸张、方向和边距，以及选择打印机，否则系统会选用默认打印机进行打印。</p> -->
<!-- 	</div> -->
</body>
</html>